Skip to content

Allow osdctl rhobs logs to accept HCP cluster IDs#893

Merged
dustman9000 merged 1 commit into
openshift:masterfrom
dustman9000:rhobs-logs-hcp-support
May 15, 2026
Merged

Allow osdctl rhobs logs to accept HCP cluster IDs#893
dustman9000 merged 1 commit into
openshift:masterfrom
dustman9000:rhobs-logs-hcp-support

Conversation

@dustman9000
Copy link
Copy Markdown
Member

@dustman9000 dustman9000 commented May 15, 2026

Previously osdctl rhobs logs rejected HCP cluster IDs with an error telling users to find the parent MC ID. This was a UX regression from osdctl dt logs which accepted any cluster ID.

Now HCP IDs are auto-resolved to their parent MC (same as osdctl rhobs metrics already did). The HCP external ID is still used for the openshift_cluster_id log filter so logs are correctly scoped to the HCP.

All three osdctl rhobs subcommands (metrics, logs, cell) now accept any cluster ID (HCP, MC, or SC).

Usage examples

# Logs with HCP cluster ID (auto-resolves to parent MC) in the openshift-monitoring (MC namespace)
osdctl rhobs logs -C <hcp-cluster-id> -n openshift-monitoring --since 1h

# Logs with MC cluster ID (works as before)
osdctl rhobs logs -C <mc-cluster-id> -n openshift-monitoring --since 1h

# Logs for a specific pod (positional arg)
osdctl rhobs logs -C <cluster-id> prometheus-k8s-0 -n openshift-monitoring --since 1h

# Logs for a specific container
osdctl rhobs logs -C <cluster-id> -n <hcp-namespace> -c kube-apiserver --since 1h

# Text search
osdctl rhobs logs -C <cluster-id> -n <hcp-namespace> --contain OOMKilled --since 1h

# Regex filter (server-side, fast)
osdctl rhobs logs -C <cluster-id> -n <hcp-namespace> --contain-regex '(?i)(error|timeout)' --since 30m

# Error level only
osdctl rhobs logs -C <cluster-id> -n <hcp-namespace> --level error --since 1h

Tested

  • HCP cluster ID: auto-resolves to MC, filters by HCP external ID
  • MC cluster ID: works as before
  • Positional pod name: prometheus-k8s-0 filters correctly
  • Namespace, container, contain, regex, level flags: all work

Also updates the MCP tool description to reflect that any cluster ID is accepted.

Fixes: https://github.com/openshift/ops-sop/pull/3993

Summary by CodeRabbit

  • Bug Fixes
    • The rhobs_logs tool now accepts any cluster ID, with Hosted Control Plane (HCP) cluster IDs automatically resolved to their parent Management Cluster for log resolution.

Remove the early return that rejected HCP cluster IDs for log queries.
HCP IDs are now auto-resolved to their parent MC, matching the behavior
that metrics already had. The HCP external ID is still used for the
openshift_cluster_id log filter.

This simplifies the UX by accepting any cluster ID (HCP, MC, or SC)
for all three osdctl rhobs subcommands (metrics, logs, cell).
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

Walkthrough

The PR updates the RHOBS MCP logs tool to accept HCP cluster IDs in addition to MC cluster IDs. HCP cluster IDs are automatically resolved to their parent management cluster for RHOBS queries. Documentation and implementation are aligned: tool schema is updated to reflect the broadened input, and the cluster resolution logic removes the prior HCP rejection for logs.

Changes

HCP cluster ID support for RHOBS logs

Layer / File(s) Summary
MCP tool schema and documentation
cmd/rhobs/mcp_tools.go
The rhobs_logs tool's Description and cluster_id field schema are updated to accept any cluster ID, explicitly stating that HCP IDs auto-resolve to the parent MC.
HCP cluster resolution in CreateRhobsFetcher
cmd/rhobs/requests.go
The HCP branch now always resolves monitoredClusterId to the management cluster and logs that the MC is used for RHOBS resolution, removing the prior logs-specific error rejection.

Possibly related PRs

  • openshift/osdctl#892: Main PR that introduces the MCP server behavior; this PR adjusts the RHOBS MCP schema and HCP cluster resolution logic that directly impacts that feature.

Suggested labels

lgtm

Suggested reviewers

  • petrkotas
  • MateSaary

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (11 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: enabling the rhobs logs command to accept HCP (Hosted Control Plane) cluster IDs, which is the primary objective of this pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The custom check for Ginkgo test names is not applicable. The PR modifies only non-test files and the repository uses standard Go testing, not Ginkgo.
Test Structure And Quality ✅ Passed The PR adds mcp_test.go which uses Go's standard testing package, not Ginkgo. The custom check is specific to Ginkgo test code quality, making it not applicable to this PR.
Microshift Test Compatibility ✅ Passed The custom check applies to new Ginkgo e2e tests. This PR contains only CLI tool implementation changes (mcp_tools.go and requests.go) with no new Ginkgo e2e tests. The check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR does not add any Ginkgo e2e tests. It only modifies two regular Go source files (mcp_tools.go and requests.go) in the osdctl command tool. The custom check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies CLI tool utilities for RHOBS cluster ID resolution. No deployment manifests, operator code, controllers, or scheduling constraints introduced.
Ote Binary Stdout Contract ✅ Passed Check not applicable. PR modifies osdctl CLI tool, not OTE binary. Changes are documentation strings and regular library function, not process-level code.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No Ginkgo e2e tests are added in this PR. The PR modifies CLI tool functionality using standard Go testing, not Ginkgo BDD framework. Custom check does not apply.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 15, 2026
@joshbranham
Copy link
Copy Markdown
Contributor

/lgtm
/approve

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 15, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 15, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dustman9000, joshbranham

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [dustman9000,joshbranham]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dustman9000
Copy link
Copy Markdown
Member Author

/retest

@dustman9000 dustman9000 merged commit b0b917b into openshift:master May 15, 2026
7 checks passed
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 15, 2026

@dustman9000: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/format af5bf0c link unknown /test format

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants